export default {
  namespaced: true,
  state: () => ({
    token: uni.getStorageSync('token') || '',
    userinfo : JSON.parse(uni.getStorageSync('userinfo') || '{}'),
    redirectInfo: null // 用来记录用户登录重定向
  }),
  mutations: {
    updataRedirectInfo (state, obj) {
      state.redirectInfo = obj
    },
    updataUserinfo(state, data) {
      state.userinfo = data
      this.commit('muser/saveUserinfo')
    },
    saveUserinfo(state) { // 持久化用户信息
      uni.setStorageSync('userinfo', JSON.stringify(state.userinfo))
    },
    updataToken(state, data) {
      state.token = data
      this.commit('muser/saveToken')
    },
    saveToken(state) { // 持久化用户token
      uni.setStorageSync('token', JSON.stringify(state.token))
    }
  }
  
}